<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var num=prompt('请输入一个三位数');
        num=Number(num);
        num=parseInt(num);
        if(num>=100&&num<=999){
            bai=parseInt(num/100);
        shi=parseInt((num%100)/10);
        ge=num%10;
        console.log(bai+shi+ge);
        }else{
            alert('请输入一个正确的三位数');
        }
        
        
    </script>
</body>
</html>